iT邦幫忙

2025 iThome 鐵人賽

DAY 4
0

如同基本的函數式程式設計一般,Typst 內的所有函數都必須以純函數 (pure function) 的方式實作。唯一的例外是一些原生型別的操作,例如陣列的 "push" 等。雖然使用上不如平常寫程式方便,但是以排版文件來說,這實在是有夠方便啊!

範例一:快速排序法

可以透過 Typst 把快速排序法的遞迴樹展開並且顯示出來~

https://ithelp.ithome.com.tw/upload/images/20250818/20112376NrUUnFKeu9.png

成果如下:

https://ithelp.ithome.com.tw/upload/images/20250818/20112376U3QVz5HAcH.png

範例二:輸出河內塔的操作過程

很經典的河內塔問題也可以顯示出來~

https://ithelp.ithome.com.tw/upload/images/20250818/20112376T0B9NB7bHY.png

成果如下:

https://ithelp.ithome.com.tw/upload/images/20250818/20112376DpkA7LJtpU.png

範例三:輸出資料夾的樹狀結構

可以利用 list 的功能輕鬆排版樹狀結構~

https://ithelp.ithome.com.tw/upload/images/20250818/20112376FJG7P3Ds3E.png

https://ithelp.ithome.com.tw/upload/images/20250818/20112376rNstTJwlzi.png


上一篇
Day 3: 修改文字樣式
下一篇
Day 5: 簡易互動模式
系列文
Typst 與 CeTZ:對演算法與程式設計超友好的排版製圖工具19
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言